#|# Load the zen4R librarylibrary(zen4R)library(openalexR)
Thank you for using openalexR!
To acknowledge our work, please cite the package by calling `citation("openalexR")`.
To suppress this message, add `openalexR.message = suppressed` to your .Renviron file.
Show the code
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Show the code
fn <-file.path("data", "ipbes_zenodo_records")if (!file.exists(paste0(fn, ".rds"))) {# Authenticate with Zenodo zen <- ZenodoManager$new(token =Sys.getenv("Zenodo_IPBES_RO"))# Get the community ID community_id <-"ipbes"# Get the community info community <- zen$getCommunityById(community_id)# Get all deposits with ipbes somwhere ipbes_zenodo <- zen$getRecords(community_id)# Filter records based on the community ID ipbes <-sapply( ipbes_zenodo,function(record) {"ipbes"%in%unlist(record$metadata$communities) } ) ipbes_zenodo <- ipbes_zenodo[ipbes]rm(ipbes)saveRDS(ipbes_zenodo, paste0(fn, ".rds"))} else { ipbes_zenodo <-readRDS(paste0(fn, ".rds"))}
Get the dois and titles of the records
Show the code
dois <-data.frame()for (i inseq(length.out =length(ipbes_zenodo))) { record <- ipbes_zenodo[[i]] dois <-rbind( dois,c(doi = record$metadata$doi,year = record$metadata$publication_date,title = record$metadata$title ) )}names(dois) <-c("doi", "year", "title")dois <- tibble::as_tibble(dois)